; DATA TYPEs
DATA_INIT()
DATA_INIT(){
global

Int_bytes	:= 4 	; DWORD
UInt_bytes	:= 4	
float_bytes	:= 4

Char_bytes	:= 1
Short_bytes := 2 	; WORD
;------------------------------
;Size Informations
UINT_MIN	:=  0000000000
UINT_MAX	:=  4294967295

INT_MIN		:= -2147483648
INT_MAX		:=  2147483647

DATA_KNOWN_TYPES	:= "int,uint,char,short,float"
}
/*
;###############################################
DATA_INIT()
VarSetCapacity(struct,8,0)

sNUMPUT(100,struct,0,"Uint")
sNUMPUT(200,struct,4,"Uint")

msgbox % Numget(struct,0,"Uint") "/" Numget(struct,4,"Uint")

;##################################################
exitapp
*/

/*****************************************************
DATA_CHECK(int,type)
;this is made to detect bufferoverflows
******************************************************
*/
DATA_CHECK(n,type){
global	
	If(int = ""){
		return, true
	}
	DATA_TYPES	:= "Uint,int"
	If type not in %DATA_TYPES%
	{
		msgbox,16, Error Datatype check, Unsupported DATATYPE %type%
	}
	IF(%type%_MAX < n or n < %type%_MIN){
		msgbox,64,BUFFEROVERFLOW Protection, Warning: `tPrevented a bufferoverflow in PHY! Information: `nUint max `t{%UINT_MAX%}`nVAR has `t{%int%}
		return, false
	}
	return, true
} ;****************************************************


/*****************************************************
sNUMPUT(n,byref struct,offset=0,type="")
Secure Numput

provides secure copying of variable in a struct
******************************************************
*/
sNUMPUT(n,byref struct,offset=0,type=""){
	Type := type = "" ? "Uint" :  type	;default is Uint
	If(DATA_TYPE_EXIST(type)){
		VarSetCapacity(var,%type%_bytes,0)
		NumPut(n,var,0,type)
		return,	NumPut(Numget(var,0,type), struct,offset,type)
	}else{
		msgbox,16,ERROR DATA, Unknown type specified: %type%
		return, false
	}
}

DATA_TYPE_EXIST(type){
global
	If(type = ""){
			return, false
	}
	If type in %DATA_KNOWN_TYPES%
		return, true
	else
		return, false
}